﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using 简单三层架构.BLL;
using 简单三层架构.Model;

namespace 简单三层架构
{
    public partial class Buy : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void btnOK_Click(object sender, EventArgs e)
        {
            Cart bllCart;

            if (Session["cart"] == null)
            {
                bllCart = new Cart();
            }
            else
            {
                bllCart = Session["cart"] as Cart;
            }

            LineItemInfo lineItem = new LineItemInfo();
            lineItem.ItemId = Convert.ToInt32(Request.QueryString["itemid"]);
            lineItem.Quantity = Convert.ToInt32(txtQuantity.Text);
            lineItem.UnitPrice = new Item().GetItem(lineItem.ItemId).Price;

            bllCart.Add(lineItem);

            Session["cart"] = bllCart;
            Response.Redirect("ShowCart.aspx");
        }
    }
}